#ifndef ADC_H
#define ADC_H
#include <stdint.h>

typedef struct {
	uint32_t nplc;//nplc
	uint32_t nplcTimeCT;  //积分时间设置
	uint32_t nplcTimeCT_Cur; //当前积分时间设置值
	uint32_t shortPluse;  //短脉冲时间
	uint32_t shortPluse_Cur; //当前短脉冲设置
	uint16_t channel; //当前通道
	uint16_t channel_Cur; //当前通道设定值
	uint16_t adcHigh; //ADC高阈值
	uint16_t adcHigh_Cur;
	uint16_t adcLow;  //ADC底阈值
	uint16_t adcLow_Cur;
	uint8_t az;
	uint8_t az_Cur;
	uint8_t displayType;
	uint8_t type;
	double zeroP;
	double zeroN;
	double refRatio;
	double refCT;
	double fastF;
	uint32_t update;
} ADC_Ctrl;

typedef struct {
	double preResult;
	double preValue;
	double differ;
	uint32_t isZero;
	double totalP;
	double totalN;
	uint32_t sumST;
	uint32_t countST;
	float valueSt;
} ADC_Status;

__packed typedef struct {
	char startFlag[2];
	uint16_t status;
	uint32_t refp; //正基runup准打开时间
	uint32_t refn; //副基runup准打开时间
	uint32_t runDown1;
	uint32_t runUp2;
	uint32_t runDown2;
	float step;
	float remain;
	float cha;
	double totalP;
	double totalN;
	double calcN;
	double result;
	char endFlag[2];
} ADC_Result;

extern ADC_Ctrl g_adc_ctrl;
extern ADC_Status g_adc_status;
extern ADC_Result g_adc_Result;

void ADC_CtrlInit(void);

void ADC_Core(void);

#endif
